package cn.bellychang.ood.atmsimulator;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ChangLiang
 * @date 2020/5/21
 */
public enum CommandLineInput {

    /**
     *
     */
    INSERT_CARD('i'),
    EJECT_CARD('e'),
    QUERY_BALANCE('q'),
    WITHDRAW('w'),
    DEPOSIT('d'),
    TRANSFER('t'),
    EXIT('s');

    private final static Map<Character, CommandLineInput> inputMap;

    static{
        inputMap = new HashMap<>();
        for (CommandLineInput input : values()) {
            inputMap.put(input.getShortCmd(), input);
        }
    }

    private final char shortCmd;

    CommandLineInput(char shortCmd) {
        this.shortCmd = shortCmd;
    }

    public char getShortCmd(){
        return shortCmd;
    }

    public static CommandLineInput getCommandLintInputForInput(char input) {
        return inputMap.get(input);
    }

}
